var org = {
    treeView:null,
    init:function(){
        this.loadData();
        this.loadEvent();
    },
    /**
     * 加载组织数据信息
     */
    loadData:function(){
        njzxw.ajax({
            url:URL.ORG.LOAD_ORG_LIST,
            data:{
                id:'',
                List:[],
                supperId:''
            },
            fun:function(a,b){
               console.log(a);
                console.log(b.data);
                if(a){
                    org.treeView = $('#tree').treeview({
                        data: b.data,
                        expandIcon: 'glyphicon glyphicon-chevron-right',
                        collapseIcon: 'glyphicon glyphicon-chevron-down',
                        nodeIcon: 'glyphicon glyphicon-bookmark',
                        showIcon:false,
                        showTags: true,
                        highlightSelected:false,
                        showCheckbox:false,
                        multiSelect:true,
                        showDeleteIcon:true,
                        showModifyIcon:true,
                        onNodeDelete:function(event, node){
                            //删除菜单
                            org.deleteOrg(node);
                        },
                        onNodeModify:function(event, node){
                            org.modifyOrg(node);
                        }
                    });
                }else{

                }
            }
        });
    },
    /**
     * 删除组织
     */
    deleteOrg:function(node){
        njzxw.delete({
            msg:'确定要删除【'+node.text+'】组织吗？',
            url:URL.ORG.DELETE_URL,
            data:{
                id:node.id
            }
        })
    },
    /**
     * 修改组织
     */
    modifyOrg:function(node){
        console.log('===-=>',node);
        njzxw.openWindow({
            id:'orgadd',
            title:'组织修改【'+(node.text)+'】',
            content:'../html/sys/org/addOrg.html?id='+node.id
        });
    },
    /**
     * 加载文本框事件
     */
    loadEvent:function(){
        $('#orgName').on('input',function(){
            if(org.treeView != null){
                var orgName = $('#orgName').val();
                org.treeView.treeview('search', [ orgName, { attribute:'text',ignoreCase: false, exactMatch: false } ])
            }
        });
    }
}